function setUp(){
	
	PicBoard.getTranslations(['lang_242_deleteImgConfirm', 'lang_322_donateConfirm', 'lang_51_yes', 'lang_52_no'], function(){});
			
	$('#controlArea').css({
		'margin-top': '27px',
		'height': $('#UserResultArea').height() 
	});

	// Bind buttons
	
	$('#saveEdits').bind('click', function(){
		// Clicking the save button should send the gID, group name and description to the server and wait for a response.
		$.post(PicBoard.baseURL + "rsrc.php?req=updateImage", { imgID: $('input#imgID').val(), name: $('input#groupName').val(), description: $('textarea#groupDescription').val() }, function(data){
			if(data.statusCode == 200){
				// Update the side selector with the new name.
				$('select#groupSelector').children('option:selected').html( $('input#groupName').val() );
				
				alert(data.message);
			} else {
				alert(data.message);
			}
		}, 'json');			
		
	});
	
	$('#deleteBook').bind('click', function(){
		check = confirm(PicBoard.languageMap.lang_242_deleteImgConfirm);
	
		if(check){	
			$.post(PicBoard.baseURL + "rsrc.php?req=deleteImage", { id: $('input#imgID').val() }, function(data){
				if(data.statusCode == 200){
					window.location = "home";
				} else {
					alert(data.message);
				}
			}, 'json');	
		}
	});
	
	$('#donateGroup').bind('click', function(){
		// We need to deep-check the book to see if it has any assets that cannot be published.
		
		if($('select#donateSelector').val() != 0 && $('select#donateAlbum').val() != ""){
		
			$.post(PicBoard.baseURL + "rsrc.php?req=donateImage", { imageID: $('input#imgID').val(), groupID: $('select#donateSelector').val(), albumID: $('select#donateAlbum').val() }, function(data){
				// Response from the server for request to donate
				if(data.statusCode == 200){
					jQuery.facebox.close();
					alert(data.message);
				} else {
					alert(data.message);
				}
			}, 'json');		
		
		} else {
			alert("Please select a group and a group album before donating.");
		}

	});
	
	$('#donateSelector').bind('change', function(){
		// 0 is the default non-selected option.
		if($(this).val() != 0){
			$.post(PicBoard.baseURL + "rsrc.php?req=getGroupAlbums", { gID: $(this).val() }, function(data){
				$('#donateAlbum').children().remove();
				for(i in data.albums){
					$('#donateAlbum').append(
						$('<option>', { val: data.albums[i].isID, text: data.albums[i].name })
					);
				}
				
			}, 'json');
		} else {
			// Remove all options from the other select element
			$('#donateAlbum').children().remove();
		}
	});
	
	$('#unDonate').bind('click', function(){
		if($('select#retrieveSelector').val() == "") return;
		$.post(PicBoard.baseURL + "rsrc.php?req=retrieveImage", { imageID: $('#imgID').val(), groupID: $('select#retrieveSelector').val(), albumID: $('select#retrieveAlbum').val() }, function(data){	
			if(data.statusCode == 200){
				// Remove the item from the select
				$('select#retrieveSelector').children("option:selected").remove();
				alert(data.message);
			} else {
				alert(data.message);
			}
		}, 'json');	
	});
	
	$('#groupSelector').bind('change', function(){
		window.location = "managephotos?id=" + $(this).val();
	});
	
}

PicBoard.addLoadEvent( "setUp()" );